package me.keiwu.user.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;

/**
 * Created by kei on 06/03/2018.
 */
@NoRepositoryBean
public interface  BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {


    @Query(value = "select * from #{#entityName} where ?1=?2", nativeQuery = true)
    T find(String field, String value);

    @Query(value = "select * from #{#entityName} where ?1=?2 and ?3=?4", nativeQuery = true)
    T find(String field1, String value1, String field2, String value2);

    @Query(value = "select * from #{#entityName} where ?1=?2 and ?3=?4 and ?5=?6", nativeQuery = true)
    T find(String field1, String value1, String field2, String value2, String field3, String value3);


}
